package com.huizu.project.service.impl;

import java.util.List;

import cn.hutool.core.util.ObjectUtil;
import com.huizu.common.exception.ServiceException;
import com.huizu.common.utils.DateUtils;
import com.huizu.common.utils.SnowFlake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.huizu.project.mapper.ProLdDjMapper;
import com.huizu.project.domain.ProLdDj;
import com.huizu.project.service.IProLdDjService;

/**
 * 劳动等级配置Service业务层处理
 * 
 * @author zhangmx
 * @date 2024-05-11
 */
@Service
public class ProLdDjServiceImpl implements IProLdDjService 
{
    @Autowired
    private ProLdDjMapper proLdDjMapper;

    /**
     * 查询劳动等级配置
     * 
     * @param id 劳动等级配置主键
     * @return 劳动等级配置
     */
    @Override
    public ProLdDj selectProLdDjById(String id)
    {
        return proLdDjMapper.selectProLdDjById(id);
    }

    /**
     * 查询劳动等级配置列表
     * 
     * @param proLdDj 劳动等级配置
     * @return 劳动等级配置
     */
    @Override
    public List<ProLdDj> selectProLdDjList(ProLdDj proLdDj)
    {
        return proLdDjMapper.selectProLdDjList(proLdDj);
    }

    /**
     * 新增劳动等级配置
     * 
     * @param proLdDj 劳动等级配置
     * @return 结果
     */
    @Override
    public int insertProLdDj(ProLdDj proLdDj)
    {
        proLdDj.setId(String.valueOf(SnowFlake.nextId()));
        proLdDj.setCreateTime(DateUtils.getNowDate());
        return proLdDjMapper.insertProLdDj(proLdDj);
    }

    /**
     * 修改劳动等级配置
     * 
     * @param proLdDj 劳动等级配置
     * @return 结果
     */
    @Override
    public int updateProLdDj(ProLdDj proLdDj) {
        ProLdDj ldDj = proLdDjMapper.selectProLdDjByName(proLdDj.getName());
        if (ObjectUtil.isNotEmpty(ldDj)){
            throw new ServiceException("对不起，您输入的劳动等级重复[" + proLdDj.getName() + "]");
        }
        return proLdDjMapper.updateProLdDj(proLdDj);
    }

    /**
     * 批量删除劳动等级配置
     * 
     * @param ids 需要删除的劳动等级配置主键
     * @return 结果
     */
    @Override
    public int deleteProLdDjByIds(String[] ids)
    {
        return proLdDjMapper.deleteProLdDjByIds(ids);
    }

    /**
     * 删除劳动等级配置信息
     * 
     * @param id 劳动等级配置主键
     * @return 结果
     */
    @Override
    public int deleteProLdDjById(String id)
    {
        return proLdDjMapper.deleteProLdDjById(id);
    }
}
